package com.example.base.config;

import com.example.base.system.service.SysConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import sun.security.krb5.Config;

import javax.annotation.PostConstruct;
import java.text.SimpleDateFormat;
import java.util.Date;

@Slf4j
@Configuration
@Component
public class BaseSystemInitConfig {

    @Autowired
    private ConfigService configService;

    @Autowired
    private ConfigurableApplicationContext context;

    public void loadConfig(){
        try {
            log.info("开始加载系统配置 {}",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
            String path=configService.getSysConfigByKey("resource");
            path="file:"+path;
            log.info("系统路径: {}",path);
            //SpringConfig.getResourceHandlerRegistry().addResourceHandler("/r/**").addResourceLocations(path);
            //context.refresh();
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
